public class ProxySearcher implements ISearcher{
    public TrueSearch getSearcher() {
        return searcher;
    }

    public void setSearcher(TrueSearch searcher) {
        this.searcher = searcher;
    }

    public AccessValidator getValidator() {
        return validator;
    }

    public void setValidator(AccessValidator validator) {
        this.validator = validator;
    }

    public Logger getLogger() {
        return logger;
    }

    public void setLogger(Logger logger) {
        this.logger = logger;
    }

    private TrueSearch searcher = new TrueSearch(); //维持一个对真实主题的引用
    private AccessValidator validator;
    private Logger logger= new Logger();;

    public String search(String id) {
        if (this.validate(id)) {
            String result = searcher.search(id);
            this.log(id);
            return result;
        }
        else {
            return "查询失败";
        }
    }
    public boolean validate(String id) {
        validator = new AccessValidator();
        return validator.validate(id);
    }
    public void log(String id) {
        logger.log(id);
    }

}
